package com.kyxx.topics.utils;


import android.content.Context;
import android.content.SharedPreferences;

/**
 * @author Administrator 淇濆瓨鐢ㄦ埛淇℃伅鎼厤鏈湴
 */
public class SharedPreferenceUtils {

    private static SharedPreferenceUtils mUtil;
    private static final String PREFERENCE_NAME = "_ZYKJMJ";
    private static SharedPreferences mSharedPreference;
    private SharedPreferences.Editor mEditor;
    private static final String ID = "id";
    private static final String USERNAME = "username";
    private static final String NICKNAME = "nickname";
    private static final String PWD = "pwd";
    private static final String AVATAR = "avatar";
    private static final String MOBILE = "mobile";
    private static final String IMGURL = "imgurl";
    private static final String SIGNATURE = "signature";
    private static final String LOGINNAME = "loginName";
    private static final String MODE = "mode";
    private static final String OAUTH_QQ_ID = "oauth_qq_id";
    private static final String OAUTH_WX_ID = "oauth_wx_id";
    private static final String DEVICEID = "deviceId";


    private SharedPreferenceUtils(Context context) {
        mSharedPreference = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
        mEditor = mSharedPreference.edit();
    }

    public static synchronized SharedPreferenceUtils init(Context context) {
        if (mUtil == null) {
            mUtil = new SharedPreferenceUtils(context);
        }
        return mUtil;
    }

    public String getId() {
        return mSharedPreference.getString(ID, null);
    }

    public String getUsername() {
        return mSharedPreference.getString(USERNAME, null);
    }

    public String getNickname() {
        return mSharedPreference.getString(NICKNAME, null);
    }

    public String getPwd() {
        return mSharedPreference.getString(PWD, null);
    }

    public String getAvatar() {
        return mSharedPreference.getString(AVATAR, null);
    }

    public String getMobile() {
        return mSharedPreference.getString(MOBILE, null);
    }

    public String getImgurl() {
        return mSharedPreference.getString(IMGURL, null);
    }

    public String getSignature() {
        return mSharedPreference.getString(SIGNATURE, null);
    }

    public String getLoginName() {
        return mSharedPreference.getString(LOGINNAME, null);
    }

    public String getMode() {
        return mSharedPreference.getString(MODE, null);
    }

    public String getOauth_qq_id() {
        return mSharedPreference.getString(OAUTH_QQ_ID, null);
    }

    public String getOauth_wx_id() {
        return mSharedPreference.getString(OAUTH_WX_ID, null);
    }

    public String getDeviceId() {
        return mSharedPreference.getString(DEVICEID, null);
    }

    public void setId(String id) {
        mEditor.putString(ID, id);
        mEditor.commit();
    }

    public void setUsername(String username) {
        mEditor.putString(USERNAME, username);
        mEditor.commit();
    }

    public void setNickname(String nickname) {
        mEditor.putString(NICKNAME, nickname);
        mEditor.commit();
    }

    public void setPwd(String pwd) {
        mEditor.putString(PWD, pwd);
        mEditor.commit();
    }

    public void setAvatar(String avatar) {
        mEditor.putString(AVATAR, avatar);
        mEditor.commit();
    }

    public void setMobile(String mobile) {
        mEditor.putString(MOBILE, mobile);
        mEditor.commit();
    }

    public void setImgurl(String imgurl) {
        mEditor.putString(IMGURL, imgurl);
        mEditor.commit();
    }

    public void setSignature(String signature) {
        mEditor.putString(SIGNATURE, signature);
        mEditor.commit();
    }

    public void setLoginName(String loginName) {
        mEditor.putString(LOGINNAME, loginName);
        mEditor.commit();
    }

    public void setMode(String mode) {
        mEditor.putString(MODE, mode);
        mEditor.commit();
    }

    public void setOauth_qq_id(String oauth_qq_id) {
        mEditor.putString(OAUTH_QQ_ID, oauth_qq_id);
        mEditor.commit();
    }

    public void setOauth_wx_id(String oauth_wx_id) {
        mEditor.putString(OAUTH_WX_ID, oauth_wx_id);
        mEditor.commit();
    }

    public void setDeviceId(String deviceId) {
        mEditor.putString(DEVICEID, deviceId);
        mEditor.commit();
    }

    public void clear() {
        mEditor.clear();
    }
}
